package com.czk.server;

import com.czk.codec.ObjDecoder;
import com.czk.codec.ObjEncoder;
import com.czk.domain.FileTransferProtocol;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/6/1 14:14
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        ChannelPipeline pipeline = channel.pipeline();
        pipeline.addLast(new ObjDecoder(FileTransferProtocol.class));
        pipeline.addLast(new ObjEncoder(FileTransferProtocol.class));
        pipeline.addLast(new MyServerHandler());
    }
}
